<?php
////////////------------Register Action -----------------//////////
elgg_register_action("MyCourse/save", elgg_get_plugins_path() . "MyCourse/actions/MyCourse/save.php");
elgg_register_action("MyCourse/addQuestion", elgg_get_plugins_path() . "MyCourse/actions/MyCourse/addQuestion.php");
elgg_register_action("MyCourse/New", elgg_get_plugins_path() . "MyCourse/actions/MyCourse/New.php");
elgg_register_action("MyCourse/vocabulary", elgg_get_plugins_path() . "MyCourse/actions/MyCourse/vocabulary.php");
elgg_register_action("MyCourse/myLesson", elgg_get_plugins_path() . "MyCourse/actions/MyCourse/myLesson.php");
elgg_register_action("MyCourse/loadlisten", elgg_get_plugins_path() . "MyCourse/actions/MyCourse/loadlisten.php");
elgg_register_action("MyCourse/listen", elgg_get_plugins_path() . "MyCourse/actions/MyCourse/listen.php");
elgg_register_action("MyCourse/loadWrite", elgg_get_plugins_path() . "MyCourse/actions/MyCourse/loadWrite.php");
elgg_register_action("MyCourse/write", elgg_get_plugins_path() . "MyCourse/actions/MyCourse/write.php");
elgg_register_action("MyCourse/loadTest", elgg_get_plugins_path() . "MyCourse/actions/MyCourse/loadTest.php");

////////////------------End Register Action -----------------//////////


////////////------------Register Class -----------------//////////
$CONFIG->classes["Word"] = elgg_get_plugins_path() . 'MyCourse/model/Word.php';
$CONFIG->classes["Lesson"] = elgg_get_plugins_path() . 'MyCourse/model/Lesson.php';
$CONFIG->classes["GetData"] = elgg_get_plugins_path() . 'MyCourse/model/MySqlDataHelper.php';
$CONFIG->classes["Listen"] = elgg_get_plugins_path() . 'MyCourse/model/Listen.php';
$CONFIG->classes["Question"] = elgg_get_plugins_path() . 'MyCourse/model/Question.php';
$CONFIG->classes["Status"] = elgg_get_plugins_path() . 'MyCourse/model/Status.php';
$CONFIG->classes["Write"] = elgg_get_plugins_path() . 'MyCourse/model/Write.php';
$CONFIG->classes["MySqlDataAccessHelper"] = elgg_get_plugins_path() . 'MyCourse/model/MySqlDataAccessHelper.php';
////////////------------End Register Class -----------------//////////  

elgg_register_page_handler('MyCourse', 'MyCourse_page_handler');
elgg_register_event_handler('init', 'system', 'MyCourse_init');

////////////------------End Register css -----------------//////////  
elgg_register_event_handler('init', 'system', 'mytheme_init');
////////////------------End Register css -----------------//////////  

function mytheme_init() {
    elgg_extend_view('css/elgg', 'MyCourse/css');
}

function MyCourse_init() {
    // add a site navigation item
    $item = new ElggMenuItem('MyCourse', elgg_echo('MyCourse:title'), 'MyCourse/myCourse');
    elgg_register_menu_item('site', $item);
}

function MyCourse_page_handler($segments) {
    switch ($segments[0]) {
        default :
            ////////////------------Register Pages -----------------//////////    
        case 'myCourse' :
            include elgg_get_plugins_path() . 'MyCourse/pages/MyCourse/myCourse.php';
            break;
        case 'myLesson' :
            include elgg_get_plugins_path() . 'MyCourse/pages/MyCourse/myLesson.php';
            break;
        case 'vocabulary' :
            include elgg_get_plugins_path() . 'MyCourse/pages/MyCourse/vocabulary.php';
            break;

        case 'listen' :
            include elgg_get_plugins_path() . 'MyCourse/pages/MyCourse/listen.php';
            break;
        
         case 'write' :
            include elgg_get_plugins_path() . 'MyCourse/pages/MyCourse/write.php';
            break;
        case 'test' :
            include elgg_get_plugins_path() . 'MyCourse/pages/MyCourse/test.php';
            break;
        ////////////------------End Register page -----------------//////////  

////////////------------Register AJAX -----------------//////////        
        case 'loadWord' :
            include elgg_get_plugins_path() . 'MyCourse/AJAX/loadWord.php';
            break;
        case 'loadCourse' :
            include elgg_get_plugins_path() . 'MyCourse/AJAX/loadCourse.php';
            break;
        case 'ClickNameListen' :
            include elgg_get_plugins_path() . 'MyCourse/AJAX/loadListen.php';
            break;
        case 'ClickSkipListen' :
            include elgg_get_plugins_path() . 'MyCourse/AJAX/loadListenSkip.php';
            break;
        case 'ClickTranscript' :
            include elgg_get_plugins_path() . 'MyCourse/AJAX/ViewTranscript.php';
            break;
        case 'ClickTagFriend' :
            include elgg_get_plugins_path() . 'MyCourse/AJAX/ClickTagFriend.php';
            break;
        
        case 'ClickPicture' :
            include elgg_get_plugins_path() . 'MyCourse/AJAX/ClickPicture.php';
            break;
        case 'ClickNext' :
            include elgg_get_plugins_path() . 'MyCourse/AJAX/ClickNext.php';
            break;
        ////////////------------End Register AJAX -----------------//////////       
        
    }

    return true;
}

